package com.bocek.chakmapoint.model;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 * A common interface for different types of items that can be present in a slide.
 * 
 * @author  Baris Sencan
 * @version 1.1
 */
public interface SlideItem {
	
	/**
	 * Get the type name of the slide item.
	 * 
	 * @requires Nothing.
	 * @modifies Nothing.
	 * @effects  Type name of the slide item is returned. (e.g: "Oval")
	 */
	public String getName();
	
	/**
	 * Draw the slide item on a given Graphics instance.
	 * Does nothing if the parameter is null.
	 * 
	 * @requires A non-null java.awt.Graphics object, g.
	 * @modifies Nothing.
	 * @effects  Slide item is drawn on g.
	 * @see java.awt.Graphics
	 */
	public void draw(Graphics g);
	
	/**
	 * Check if a given point is inside the slide item.
	 * 
	 * @requires A non-null java.awt.Point object, p.
	 * @modifies Nothing.
	 * @effects  Returns true if p inside the boundaries of the slide item, false otherwise.
	 * @see java.awt.Point
	 */
	public boolean isPointInside(Point p);
	
	/**
	 * Perform select action on the slide item, given a selection point.
	 * 
	 * @requires A non-null java.awt.Point object, p.
	 * @modifies Selected state of the slide item.
	 * @effects  Returns true if p can make the slide item go into a selected state, false otherwise.
	 * @see java.awt.Point
	 */
	public boolean select(Point p);
	
	/**
	 * Perform deselect action on the slide item.
	 * 
	 * @requires Nothing.
	 * @modifies Selected state of the slide item.
	 * @effects  Returns false if the slide item was not selected before the call, true otherwise.
	 */
	public boolean deselect();
	
	/**
	 * Check if the slide item is in selected state.
	 * 
	 * @requires Nothing.
	 * @modifies Nothing.
	 * @effects  Returns true if the slide item is selected, false otherwise.
	 */
	public boolean isSelected();
	
	/**
	 * Move the slide item relatively from its current position.
	 * 
	 * @requires A non-null java.awt.Point object, delta.
	 * @modifies Slide item position.
	 * @effects  Nothing.
	 * @see java.awt.Point
	 */
	public void move(Point delta);
	
	/**
	 * Check if any part of the slide item is outside a frame of given dimensions.
	 * 
	 * @requires A non-null java.awt.Dimension object, frameDimension.
	 * @modifies Nothing.
	 * @effects  Returns true if any part of the slide item is rendered outside frameDimension, false otherwise.
	 * @see java.awt.Dimension
	 */
	public boolean isOutsideFrame(Dimension frameDimension);
	public boolean intersects(Rectangle r);
	public void setThickness(int t);
	public int getThickness();
	public void setColor(Color c);
	public Color getColor();
	public void setSelected(boolean b); // omer gurlek wanted it to be added
	public Rectangle drawSelection();
	public void fill();
	public Element saveToXML(Document doc, int depth) throws ParserConfigurationException;
	
}
